<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<div class="row-fluid">
			<div class="col-sm-12">
				<form class="form-horizontal m-t " id="signupForm" method="post" enctype="multipart/form-data">
					<input type="hidden" name="id" value="${eduExp.id}" />
					<input type="hidden" name="talentsId" value="${eduExp.talentsId}" />
					<input type="hidden" name="classify" value="${eduExp.school.classify}" />
					<fieldset>
						<legend>教育经历</legend>
						<div class="workinput">
							<div class="form-group">
								<label class="col-sm-3 control-label">起止时间：</label>
								<div class="col-sm-9 form-inline">
									<input type="text" class="form-control datetime" id="e_startDate" name="startDate" readonly="readonly" placeholder="请选择起始时间" value="${eduExp.startDate}"/> -
									<select class="form-control" onchange="chooseDate(1);" id="choosedate"><option value="0" <c:if test="${schooledu.endDate =='至今' }">selected="selected"</c:if>>至今</option><option value="" <c:if test="${schooledu.endDate !='至今' }">selected="selected"</c:if>>选择年月</option></select>
									<input type="text" class="form-control datetime" id="e_endDate" name="endDate" readonly="readonly" placeholder="请选择截止时间" value="${eduExp.endDate}" <c:if test="${work.endDate =='至今' }">style="display:none;"</c:if>/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">学校名称：</label>
								<div class="col-sm-9">
								    <input type="text"  class="form-control company" id="e_schoolName" name="schoolName" value="${eduExp.schoolName}"/>
									<input type="hidden"  class="form-control" id="e_schoolId" name="schoolId" value="${eduExp.school.id}"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">专业：</label>
								<div class="col-sm-9">
									<input type="text" class="form-control" id="e_profession" name="profession" value="${eduExp.profession}"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">学历：</label>
								<div class="col-sm-9">
									<input type="text" class="form-control" id="e_education" name="education" value="${eduExp.education}"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">是否统招：</label>
								<div class="col-sm-9 ">
								    <label class="radio-inline"> <input value="1" name="unified" type="radio" <c:if test="${eduExp.unified eq 1 }">checked="checked" </c:if>> 是</label>
								    <label class="radio-inline"> <input value="0" name="unified" type="radio" <c:if test="${eduExp.unified eq 0 }">checked="checked" </c:if>> 否</label>
								    
								</div>
							</div>
						</div>
					</fieldset>
					<div class="form-group" style="text-align: center;">
						<div class="col-sm-12">
							<button class="btn btn-primary" type="button" id="sub">提交</button>
							<button class="btn btn-primary" type="button"
								onclick="top.Dialog.close();">取消</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	 $(function () {
		 $("#e_schoolName").autosuggest({
	            url: '<%=contextPath%>/school/getJsonSchool?type=1',
	                minLength: 1,
	                maxNum: 4,
	                align: 'center',
	                method: 'post',
	                highlight: true,
	                immediate: true,
	                queryParamName: 'name',
	                nextStep: function (ele) {
	                    var tid = ele.data('id'); 
	                    $("#e_schoolId").val(tid);
	                },
	                split: ' ',
	                open: function(){
	                    //console.log("start open");
	                },
	                close: function(){
	                    //console.log("start close");
	                }
	            });
		 $('.datetime').datetimepicker({
			    format: 'yyyy-mm',
		        autoclose: true,
		        todayBtn: true,
		        startView: 'year',
		        minView:'year',
		        maxView:'decade',
		        language:  'zh-CN',
	    	    autoclose: 1//选择后自动关闭
		  });
		 //$("#e_startDate").datetimepicker("update",'2002-09');//赋值
		 $('#e_startDate1').datetimepicker({
	    	 format: 'yyyy-mm',
		        autoclose: true,
		        todayBtn: true,
		        startView: 'year',
		        minView:'year',
		        maxView:'decade',
		        language:  'zh-CN',
	    	    autoclose: 1//选择后自动关闭
	  }).on('hide', function(event) {
		  var year = event.date.getFullYear();//获取年
		  var newyear = year+4;
		  $("#e_endDate").datetimepicker("update",newyear+'-07');//赋值
		});
        $("#sub").click(function () {
        	//批量验证表单非空
        	var arr=new Array(
              new Array('e_startDate','开始日期未选择!'),
              new Array('e_endDate','结束日期未选择!'),
        	  new Array('e_schoolName','学校未填写!'),
        	  new Array('e_profession','专业未填写!'),
        	  new Array('e_education','学历未填写!')
        	)
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  }
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/edu/editSingle',
                data:{'num':1},
				type : 'post',
				dataType : "json",
				 beforeSend: function () {
				        // 禁用按钮防止重复提交
						$("#sub").attr("disabled","disabled");
						swal("信息已经提交，请等待后台处理~！");
				    },
					success : function(data) {
						if (data.code == 200) {
							swal({
								title : data.message,
								type : "success",
								showCancelButton : false,
								confirmButtonText : "确定",
								animation : "slide-from-bottom",
								text: "2秒后自动关闭。", 
		      	    			timer: 2000, 
								closeOnConfirm : true
							}, function() {
								top.Dialog.close();
							});
						} else {
							swal("错误", data.message, "error");
						}  
					},    
					complete: function () {
				        $("#sub").removeAttr("disabled");
				    },
				    error: function (data) {
				    	swal("错误", data.message, "error");
				    }
			});
		});
	});
	</script>
</body>
</html>